package com.hzsai.mininote.repository;

import com.hzsai.mininote.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

@Repository
public interface JpaUserRepository extends JpaRepository<User, Long> {

    boolean existsByName(String name);

    /**
     * '#{#entityName}'是SPel形式拼写，获取对应实体名字@Entity(name = xx)
     *
     * @param id
     * @return
     */
    @Query("update #{#entityName} set deleted = 'T' where id =:id ")
    boolean markAsDeleteById(@Param("id") long id);
}
